package zip;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.util.Zip4jConstants;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

/**
 * Created by jinju on 2016/5/5.
 */
public class MainTest {
    public static void main(String[] args) {
        try {
            final ZipFile zipFile = new ZipFile("f:\\zipTest.zip");
            final ArrayList<File> fileAddZip = new ArrayList<File>();
            fileAddZip.add(new File("f:\\ZipTestExcel.xls"));
            final ZipParameters parameters = new ZipParameters();
            parameters.setEncryptFiles(true);
            parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
            parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
            parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
            parameters.setPassword("123");
            zipFile.createZipFile(fileAddZip, parameters);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
